package com.clothing.customization.controller.designer;

import com.clothing.customization.dto.TaskInfoDTO;
import com.clothing.customization.dto.TaskInfoQueryDTO;
import com.clothing.customization.service.TaskInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

@RestController
@RequestMapping("/api/designer/task")
@RequiredArgsConstructor
@PreAuthorize("hasRole('DESIGNER')")
public class TaskInfoController {

    private final TaskInfoService taskInfoService;

    @GetMapping("/list")
    public Page<TaskInfoDTO> getTaskList(TaskInfoQueryDTO queryDTO) {
        return taskInfoService.getTaskList(queryDTO);
    }

    @GetMapping("/{id}")
    public TaskInfoDTO getTaskDetail(@PathVariable Long id) {
        return taskInfoService.getTaskDetail(id);
    }

    @PostMapping
    public TaskInfoDTO createTask(@Valid @RequestBody TaskInfoDTO taskDTO) {
        return taskInfoService.createTask(taskDTO);
    }

    @PutMapping("/{id}")
    public TaskInfoDTO updateTask(@PathVariable Long id, @Valid @RequestBody TaskInfoDTO taskDTO) {
        return taskInfoService.updateTask(id, taskDTO);
    }

    @DeleteMapping("/{id}")
    public void deleteTask(@PathVariable Long id) {
        taskInfoService.deleteTask(id);
    }

    @PutMapping("/{id}/status")
    public void updateTaskStatus(@PathVariable Long id, @RequestParam String status) {
        taskInfoService.updateTaskStatus(id, status);
    }
} 